class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-08-14",
      revision: "8251bd238f28f4b698428180c7b637428a8a4385"
  version "2021-08-14"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "9fb47fba2d0f9050880e2644198ac067cbf519d14796014114bc68bb5c8af454"
    sha256 cellar: :any_skip_relocation, big_sur:       "18b1aed9f5060f9b0f14f20cf4aaff0e55f44cea44e6d6cfb696fd6f00a8323d"
    sha256 cellar: :any_skip_relocation, catalina:      "7864c7eabb7836a601309fe8c2e152ba4e2541eede00d83de1160a0d8a583a36"
    sha256 cellar: :any_skip_relocation, mojave:        "479865cacc5fe86f639bcb34d71a37ddf10af74825fb1f9f45fadbc418667db7"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "c63b0799d8fe6a551f358471513b89a75133ca10a03824c4b439b0b2e4d352dd"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
